package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManagerService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author ：MJS
 * @date ：Created in 2021/5/12  15:17
 * @description：此类是为了其他微服务远程调用 所使用
 */
@RestController
@Api(description = "商品微服务")
@RequestMapping("/api/product")
public class ProductApiController {
    @Autowired
    private ManagerService managerService;
    //】https://item.jd.com/12312314123.html   商品详情页面 入参：skuId
    //1.skuInfo 库存信息 及图片   /inner字样表示 内部资源  不允许外部访问  网关全局过滤器
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId){
        return managerService.getSkuInfo(skuId);
    }
    //2.一二三级分类
    @GetMapping("/inner/getBaseCategoryView/{category3Id}")
    public BaseCategoryView getBaseCategoryView(@PathVariable Long category3Id){
        return managerService.getBaseCategoryView(category3Id);
    }
    //3.销售属性及值及选中红边框
    @GetMapping("/inner/getSpuSaleAttrValueChecked/{skuId}/{spuId}")
    public List <SpuSaleAttr> getSpuSaleAttrValueChecked(@PathVariable Long skuId,
                                                         @PathVariable Long spuId){
        return managerService.getSpuSaleAttrValueChecked(skuId,spuId);
    }
    //4.销售属性值组合对应的skuId
    @GetMapping("/inner/getValueSkuJson/{spuId}")
    public Map getValueSkuJson(@PathVariable Long spuId){
    return managerService.getValueSkuJson(spuId);
    }
    //5.单独查询价格 不放在缓存中
    @GetMapping("/inner/getPrice/{skuId}")
    public BigDecimal getPrice(@PathVariable Long skuId){
        return managerService.getPrice(skuId);
    }
    //查询三级分类视图集合
    @GetMapping("/inner/getBaseCategoryViewList")
    public List<BaseCategoryView>getBaseCategoryViewList(){
        return managerService.getBaseCategoryViewList();
    }
    //根据主键查询品牌对象
    @GetMapping("/inner/getBaseTrademark/{id}")
    public BaseTrademark getBaseTrademark(@PathVariable Long id){
        return managerService.getBaseTrademark(id);
    }
    //查询ES索引库所需要的平台属性ID及名称及值
    @GetMapping("/inner/getSkuAttrValue/{skuId}")
    public List<SkuAttrValue>getSkuAttrValue(@PathVariable Long skuId){
     return managerService.getSkuAttrValue(skuId);
    }
}
